package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.common.R;
import com.itheima.reggie.entity.Orders;
import com.itheima.reggie.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 订单
 */
@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("/submit")
    public R submit(@RequestBody Orders orders) {

        orderService.submit(orders);
        return R.success("下单成功");
    }
    //订单明细 （查询展示）
    @GetMapping("/page")
    public R findByPageAndCondition(Integer page, Integer pageSize, Integer number, String beginTime, String endTime) {
        return orderService.findByPageAndCondition(page, pageSize, number, beginTime, endTime);
    }
    //最新订单查询-历史订单//要从最近到前
    @GetMapping("/userPage")
    public R findByPage(Integer page, Integer pageSize){
        return orderService.findByPage(page,pageSize);
    }







}